package com.zenglx.demo;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Configuration
public class AssemblyWebAutoConfigure {
    @Bean
    public Docket createAssemblyWebRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).groupName("组件测试")
                .ignoredParameterTypes(HttpServletRequest.class).ignoredParameterTypes(HttpSession.class).select()
                .apis(RequestHandlerSelectors.basePackage("com.zenglx.demo")).paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("组件开发小组", "http://localhost/", "zengliangxiwei@163.com");
        return new ApiInfoBuilder()
                .title("组件测试")
                .description("组件测试 Web API")
                .termsOfServiceUrl("http://www.zenglx.com")
                .contact(contact).version("1.0.0").build();
    }
}
